package org.springsource.batch;

import org.springframework.batch.item.ItemProcessor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.social.twitter.api.Tweet;
import org.springframework.social.twitter.api.Twitter;
import org.springframework.stereotype.Component;
import org.springsocial.domain.ExtendedTweet;
import org.springsocial.services.PlayerService;
import org.springsocial.services.TweetService;

@Component("proc")
public class ExampleItemProcessor implements ItemProcessor<Tweet, ExtendedTweet>{
	
	@Autowired Twitter twitter;
	@Autowired PlayerService playerService;
	@Autowired TweetService tweetService;
	
	@Override
	public ExtendedTweet process(Tweet arg0) throws Exception {
		System.out.println("in processor");
		return buildExtendedTweet(arg0);
	}
	private ExtendedTweet buildExtendedTweet(Tweet tweet){
		ExtendedTweet extTweet = new ExtendedTweet();
		extTweet.setCreatedAt(tweet.getCreatedAt());
		extTweet.setFromUser(tweet.getFromUser());
		extTweet.setFromUserId(tweet.getFromUserId());
		extTweet.setId(tweet.getId());
		extTweet.setInReplyToStatusId(tweet.getInReplyToStatusId());
		extTweet.setLanguageCode(tweet.getLanguageCode());
		extTweet.setProfileImageUrl(tweet.getProfileImageUrl());
		extTweet.setRetweetCount(tweet.getRetweetCount());
		extTweet.setSource(tweet.getSource());
		extTweet.setText(tweet.getText());
		extTweet.setToUserId(tweet.getToUserId());
		return extTweet;
	}
	 
}
